<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
    <title>DedeCMSV6系统概况</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <base target="_self">
    <link rel="stylesheet" href="../static/css/bootstrap.min.css">
    <link href="../static/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/base.css" />
    <link rel="stylesheet" type="text/css" href="css/indexbody.css" />
    <link href="images/style<?php echo $cfg_admin_skin;?>/style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" src="../static/js/jquery.js"></script>
    <script src="../static/js/bootstrap.bundle.js"></script>
    <script language="javascript" src="../static/js/dedeajax2.js"></script>
    <script language="javascript" src="js/indexbody.js"></script>
    <script language="javascript" src="js/main.js"></script>
    <script type="text/javascript">
        function showMore() {
            $("#allInfo").toggle();
            $("#allInfoTD").toggle();
        }

        $(function () {
            $.get("index_testenv.php", function (data) {
                if (data !== '') {
                    $("#__testEvn").html(data);
                }
            });
            $.get("index_body.php?dopost=get_seo", function (data) {
                if (data !== '') {
                    $("#SEOInfo").html(data);
                }
            });
        });
    </script>
    <style>
        .row {
            display: flex;
            flex-wrap: wrap;
        }

        .row>[class*='col-'] {
            display: flex;
            flex-direction: column;
        }

        .footer {
            padding: 10px;
        }
    </style>
</head>

<body>
    <div class="container-fluid">
        <div class="mt-3 mb-3">
            欢迎使用国内流行的内容管理系统（CMS）多端全媒体解决方案 -- <?php echo $cfg_softname; ?>
        </div>
        <div class="row">
            <div id="__testEvn" class="col-md-12"></div>
            <!--/#__testEvn-->
            <div class="col-md-6 mt-3 updatenews">
                <div class="card">
                    <div class="card-header">
                        <?php echo $cfg_soft_enname; ?> 更新消息
                    </div>
                    <!--/.card-header-->
                    <div class="card-body">
                        <div id="updateinfos">
                            <?php
                                echo "<div class='updatedvt py-3'>";
                                echo "安全操作：<a href='sys_data.php' class='btn btn-secondary btn-sm'>数据库备份/还原</a> <a href='sys_safetest.php' class='btn btn-secondary btn-sm'>病毒扫描</a> <a href='sys_repair.php' class='btn btn-secondary btn-sm'>系统错误修复</a></div>\r\n";
                                echo "<iframe name='stafrm' src='{$offUrl}&uptime={$oktime}' frameborder='0' id='stafrm' width='98%' height='100'></iframe>";
                            ?>
                        </div>
                    </div>
                    <!--/.card-body-->
                </div>
                <!--/.card-->
            </div>

            <div class="col-md-6 mt-3">
                <div class="card">
                    <div class="card-header">
                        Dede商业服务授权
                    </div>
                    <!--/.card-header-->
                    <div class="card-body" id="_systeminfo">
                        正在载入中...
                    </div>
                    <!--/.card-body-->
                </div>
                <!--/.card-->
            </div>

            <div class="col-md-6 mt-3">
                <div class="card">
                    <div class="card-header">
                        快捷操作
                        <a href='javascript:AddNew()'><b>【新增】</b></a>
                        <a href='javascript:ListAll()'><b>【管理】</b></a>
                    </div>
                    <!--/.card-header-->
                    <div class="card-body">
                        <ul class="nav">
                            <?php
                            $dtp = new DedeTagparse();
                            $dtp->SetNameSpace('menu','<','>');
                            $dtp->LoadTemplet($myIcoFile);
                            if(is_array($dtp->CTags)){
                                foreach($dtp->CTags as $ctag){
                                    $title = $ctag->GetAtt('title');
                                    $ico = $ctag->GetAtt('ico');
                                    $link = $ctag->GetAtt('link');
                                    echo "<li class='nav-item'><a class='nav-link' href='{$link}'><img src='{$ico}'> {$title}</a></li>\r\n";
                                }
                            }
                        ?>
                        </ul>
                    </div>
                    <!--/.card-body-->
                </div>
                <!--/.card-->
            </div>

            <div class="col-md-6 mt-3">
                <div class="card">
                    <div class="card-header">
                        系统基本信息
                    </div>
                    <!--/.card-header-->
                    <div class="card-body">
                        <table width="98%" class="table table-borderless">
                            <tr>
                                <td width="25%" class='nline' style="text-align:right">您的级别：</td>
                                <td class='nline'>
                                    <?php
                                if($cuserLogin->getUserType()==10) {
                                    echo "总管理员";
                            } else if($cuserLogin->getUserType()==5) {
                                echo "频道总编";
                            } else {
                                echo "信息采集员或其它管理员";
                            }
                        ?>
                                    <a href="javascript:showMore()" class="btn btn-secondary btn-sm">查看更多</a></td>
                            </tr>
                            <tr>
                                <td colspan="2" class='nline' id="allInfoTD" style="display:none">
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="allInfo"
                                        style="display:none">
                                        <tr>
                                            <td rowspan="5" class='nline' style="text-align:right">PHP环境摘要：</td>
                                            <td class='nline' style="text-align:left">
                                                PHP版本：<?php echo @phpversion(); ?>&nbsp;GD版本：<?php echo @gdversion(); ?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class='nline' style="text-align:left">是否安全模式：<font color='red'>
                                                    <?php echo ($isSafeMode ? 'On' : 'Off')?></font>
                                                <?php
                                if($isSafeMode) {
                                    echo "<br>　　<font color='blue'>由于您的系统以安全模式运行，为了确保程序兼容性，第一次进入本系统时请更改“<a href='sys_info.php'><u>更改系统参数</u></a>”里的FTP选项，并选择用FTP形式创建目录</font>";
                                }
                            ?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class='nline' style="text-align:left">
                                                Register_Globals：<font color='red'>
                                                    <?php echo ini_get("register_globals") ? 'On' : 'Off'?></font>
                                                &nbsp;
                                                Magic_Quotes_Gpc：<font color='red'>
                                                    <?php echo ini_get("magic_quotes_gpc") ? 'On' : 'Off'?></font>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class='nline' style="text-align:left">
                                                支持上传的最大文件：<?php echo ini_get("post_max_size")?></td>
                                        </tr>
                                        <tr>
                                            <td class='nline' style="text-align:left">
                                                是否允许打开远程连接：<?php echo ini_get("allow_url_fopen") ? '支持' : '不支持'; ?></td>
                                        </tr>
                                        <tr>
                                            <td class='nline' style="text-align:right"> 其它必须函数检测：</td>
                                            <td class='nline' style="text-align:left">
                                                <?php
                                $needfunc = array('dir','phpinfo');
                                $n = 0;
                                foreach($needfunc as $k) {
                                    if(!function_exists($k)) {
                                        echo "<font color='red'>[{$k}×]</font> ";
                                        $n++;
                                    }
                                }
                                if($n==0) {
                                    echo "符合要求";
                                } else {
                                echo "被禁用的函数可能导致部份功能无法使用！";
                                }
                            ?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class='nline' style="text-align:right"> 软件版本信息： </td>
                                            <td class='nline' style="text-align:left">
                                                版本名称：<?php echo $cfg_soft_enname; ?>&nbsp;版本号：<?php echo $cfg_version; ?>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!--/.card-body-->
                </div>
                <!--/.card-->
            </div>

            <div class="col-md-6 mt-3">
                <div class="card">
                    <div class="card-header">
                        信息统计
                    </div>
                    <!--/.card-header-->
                    <div class="card-body">
                        <dd id='listCount'>
                            正在载入中...
                        </dd>
                    </div>
                    <!--/.card-body-->
                </div>
                <!--/.card-->
            </div>

            <div class="col-md-6 mt-3">
                <div class="card">
                    <div class="card-header">
                        最新文档
                    </div>
                    <!--/.card-header-->
                    <div class="card-body">
                        <?php
                        $query = "SELECT arc.id, arc.arcrank, arc.title, arc.channel, ch.editcon  FROM `#@__archives` arc
                                LEFT JOIN `#@__channeltype` ch ON ch.id = arc.channel
                                 WHERE arc.arcrank<>-2 ORDER BY arc.id DESC LIMIT 0, 6 ";
                        $arcArr = array();
                        $dsql->Execute('m', $query);
                        while($row = $dsql->GetArray('m'))
                        {
                            $arcArr[] = $row;
                        }
                    ?>
                        <table width="100%" class="table table-borderless">
                            <?php
                        if(count($arcArr) > 1)
                        {
                            foreach($arcArr as $row)
                            {
                                if(trim($row['editcon'])=='') {
                                    $row['editcon'] = 'archives_edit.php';
                                }
                                $linkstr = "·<a href='{$row['editcon']}?aid={$row['id']}&channelid={$row['channel']}'>{$row['title']}</a>";
                                if($row['arcrank']==-1) $linkstr .= "<font color='red'>(未审核)</font>";
                            ?>
                            <tr>
                                <td class='nline' style="text-align:left">
                                    <?php echo $linkstr; ?>
                                </td>
                            </tr>
                            <?php
                            }
                        } else {
                        ?>
                            <tr>
                                <td class='nline' style="text-align:left">
                                    暂无新增内容
                                </td>
                            </tr>
                            <?php
                        }
                        ?>
                        </table>
                    </div>
                    <!--/.card-body-->
                </div>
                <!--/.card-->
            </div>
        </div>
    </div>


    <div class="footer">
        <!-- //底部 -->
        <div align="center" class="footer">
            Copyright &copy; 2020 <a href='https://www.dedebiz.com' target='_blank'><u>DedeCMSV6</u></a>. 版权所有 <a
                href="https://www.dedebiz.com" target="_blank" title="DedeBiz商业技术支持，提供更专业强大的站点应用开发技术">DedeBIZ技术支持</a>
        </div>

        <!--  下面是隐藏的项目  -->
        <div id='loaddiv' style='display:none'>
            <p align='center' style='padding-top:200px'><img src='images/loadinglit.gif' /> 请稍后，正在下载更新文件列表...</p>
        </div>
        <div id="editTab">
            <span id='editTabBody'>请稍候，正在载入...</span>
        </div>
        <div id="addTab">
            <form name='addform' action='index_body.php'>
                <input type='hidden' name='dopost' value='addnew' />
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td height='28' colspan='3' background="images/tbg.gif">
                            <div style='float:left'><b>增加快捷操作项</b></div>
                            <div style='float:right;padding:3px 10px 0 0;'>
                                <a href="javascript:CloseTab('addTab')"><img src="images/close.gif" width="12"
                                        height="12" border="0" /></a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="height:6px;font-size:1px;border-top:1px solid #8DA659" colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td width="20%" height="28" align="right">链接标题：</td>
                        <td width="70%">
                            <input name="title" type="text" id="title" class='pubinputs' style="width:255px;" />
                        </td>
                    </tr>
                    <tr>
                        <td height="28" width="20%" align="right">ICO图片：</td>
                        <td width="70%">
                            <input name="ico" type="text" id="ico" class='pubinputs' style="width:255px;" />
                        </td>
                    </tr>
                    <tr>
                        <td height="28" width="20%" align="right">链接网址：</td>
                        <td width="70%">
                            <input name="link" type="text" id="link" class='pubinputs' style="width:255px;" />
                        </td>
                    </tr>
                    <tr>
                        <td height="45">&nbsp;</td>
                        <td>
                            <input type="submit" name="Submit" value="保存项目" class="np coolbg"
                                style="width:80px;cursor:pointer" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

    <script>

        var dedebizInfo;

        function ViewDedeBIZ() {
            console.log(dedebizInfo);
            ShowMsg(`
            <table width="100%" class="table table-borderless"><tbody>
                        <tr>
                            <td class="nline" style="text-align:left"> 版本号： </td>
                            <td class="nline" style="text-align:left"> v${dedebizInfo.result.server_version} </td>
                        </tr>
                        
                        <tr>
                            <td class="nline" style="text-align:left"> 运行时间： </td>
                            <td class="nline" style="text-align:left"> ${dedebizInfo.result.server_run_time} </td>
                        </tr>
                        
                        <tr>
                            <td class="nline" style="text-align:left"> 服务器系统： </td>
                            <td class="nline" style="text-align:left"> ${dedebizInfo.result.server_goos}（${dedebizInfo.result.server_goarch}） </td>
                        </tr>
                        
                        <tr>
                            <td class="nline" style="text-align:left"> 内存占用： </td>
                            <td class="nline" style="text-align:left"> ${dedebizInfo.result.server_memory_usage}% </td>
                        </tr>
                        </tbody></table>
            
            `);
        }

        // 加载服务信息
        function LoadServer() {
            $.get("index_body.php?dopost=system_info", function (data) {
                let rsp = JSON.parse(data);
                if (rsp.code === 200) {
                    let infoStr = `<table width="100%" class="table table-borderless"><tbody>`;
                    if (typeof rsp.result.domain !== "undefined") {
                        infoStr += `
                        <tr>
                            <td class="nline" style="text-align:left"> 授权域名： </td>
                            <td class="nline" style="text-align:left"> ${rsp.result.domain} <a href="<?php echo $cfg_biz_dedebizUrl;?>/auth/?domain=${rsp.result.domain}"><b>【查看】</b></a> </td>
                        </tr>
                        `;
                    }
                    if (typeof rsp.result.title !== "undefined") {
                        infoStr += `
                        <tr>
                            <td class="nline" style="text-align:left"> 站点名称： </td>
                            <td class="nline" style="text-align:left"> ${rsp.result.title} </td>
                        </tr>
                        `;
                    }
                    if (typeof rsp.result.stype !== "undefined") {
                        infoStr += `
                        <tr>
                            <td class="nline" style="text-align:left"> 站点类型： </td>
                            <td class="nline" style="text-align:left"> ${rsp.result.stype} </td>
                        </tr>
                        `;
                    }
                    if (typeof rsp.result.auth_version !== "undefined" && typeof rsp.result.auth_at !== "undefined") {
                        infoStr += `
                        <tr>
                            <td class="nline" style="text-align:left"> 授权版本： </td>
                            <td class="nline" style="text-align:left"> v${rsp.result.auth_version}.x.x（时间：${rsp.result.auth_at}）</td>
                        </tr>
                        `;
                    }

                    if (rsp.result.core === null || rsp.result.core.code != 200) {
                        // 下面是DedeBIZ Core组件信息
                        infoStr += `
                        <tr>
                            <td class="nline" style="text-align:left"> Dede商业组件： </td>
                            <td class="nline" style="text-align:left"> <a class="btn btn-danger btn-sm" target="_blank" href="<?php echo $cfg_biz_dedebizUrl;?>/start?code=-1008">如何启动组件</a> </td>
                        </tr>
                        `;
                    } else {
                        dedebizInfo = JSON.parse(rsp.result.core.data);
                        infoStr += `
                        <tr>
                            <td class="nline" style="text-align:left"> Dede商业组件： </td>
                            <td class="nline" style="text-align:left"> <a class="btn btn-success btn-sm" href="javascript:ViewDedeBIZ()">查看组件信息</a> </td>
                        </tr>
                        `;
                    }
                    infoStr += "</tbody></table>";

                    $("#_systeminfo").html(infoStr);
                } else {
                    $("#_systeminfo").html(`
                    <div class="py-1">尚未启动Dede商业站点服务，原因：<b>${rsp.msg}</b></div>
                    <div class="py-1">Dede商业服务可以提升性能、增强安全、支持开源。</div>
                    <div class="py-1"><a class="btn btn-danger" target="_blank" href="<?php echo $cfg_biz_dedebizUrl;?>/start?code=${rsp.code}">开启商业服务</a></div>
                    `);
                }
            });
        }

        $(document).ready(function () {
            LoadServer();
            setInterval(function () {
                LoadServer();
            }, 5000)
        });
    </script>
</body>

</html>